package com.blr.filter;

import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.filter.CorsFilter;

import java.util.Arrays;

//@Configuration
//public class WebMvcConfig {
//    @Bean
//    FilterRegistrationBean<CorsFilter> corsFilter(){
//        FilterRegistrationBean<CorsFilter> registrationBean = new FilterRegistrationBean<>();
//        CorsConfiguration corsConfigurationcors = new CorsConfiguration();
//        corsConfigurationcors.setAllowedHeaders(Arrays.asList("*"));
//        corsConfigurationcors.setAllowedMethods(Arrays.asList("*"));
//        corsConfigurationcors.setAllowedOrigins(Arrays.asList("*"));
//        corsConfigurationcors.setMaxAge(3600L);
//        UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
//        source.registerCorsConfiguration("/**",corsConfigurationcors);
//        registrationBean.setFilter(new CorsFilter(source));
//        registrationBean.setOrder(-1);
//        return registrationBean;
//    }
//}
